#include<stdio.h>
int main()
{
	int ret = 0;
	int a, b, c, d, e, f, g, h;
	for (ret = 10000; ret < 100000; ret++)
	{
		a = ret % 10;
		b = ret / 10;
		c = ret % 100;
		d = ret / 100;
		e = ret % 1000;
		f = ret / 1000;
		g = ret % 10000;
		h = ret / 10000;
		if (ret == a * b + c * d + e * f + g * h)
			printf("%d ", ret);
	}
	return 0;
}